﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lwm.x10c.Intermediate
{
    public enum VariableTypeType
    {
        UInt16 = 0, UInt32 = 1, Int16 = 2, Int32 = 3,
        Struct = 100
    }

    public abstract class VariableType
    {
        public VariableTypeType Type { get; set; }

        public abstract string NiceName { get; }
        public abstract string DumpName { get; }

        public VariableType(VariableTypeType type)
        {
            this.Type = type;
        }
    }

    public sealed class PrimitiveType : VariableType
    {
        public static VariableType UInt16 = new PrimitiveType(VariableTypeType.UInt16);
        public static VariableType UInt32 = new PrimitiveType(VariableTypeType.UInt32);

        public PrimitiveType(VariableTypeType type) : base(type)
        {

        }

        public override string NiceName
        {
            get { return Enum.GetName(typeof(VariableTypeType), this.Type); }
        }

        private static string[] dumpNames = new string[] { "u16", "u32", "i16", "i32" };

        public override string DumpName
        {
            get { return dumpNames[(int)this.Type]; }
        }
    }

    public sealed class StructType : VariableType
    {
        public string Name { get; set; }

        public StructType() : base(VariableTypeType.Struct)
        {

        }

        public override string NiceName
        {
            get { return "Struct[" + this.Name + "]"; }
        }

        public override string DumpName
        {
            get { return "struct"; }
        }
    }
}
